package model

import (
	"team-evaluate/pkg/app"
)

type User struct {
	*Model
	Email    string `gorm:"unique;not null" json:"email"`
	Name     string `gorm:"not null" json:"name"`
	Password string `gorm:"not null" json:"password"`
	Age      uint8  `json:"age"`
	Gender   string `json:"gender"`
	Desc     string `json:"desc"`
}

type UserRes struct {
	ID     uint32 `gorm:"id" json:"id"`
	Email  string `gorm:"email" json:"email"`
	Name   string `gorm:"name" json:"name"`
	Age    uint8  `gorm:"age" json:"age"`
	Gender string `gorm:"gender" json:"gender"`
	Desc   string `gorm:"desc" json:"desc"`
}

type UserPager struct {
	List  []*User
	Pager *app.Pager
}

func (User) TableName() string {
	return "user"
}

type CreateUserRequest struct {
	Name     string `form:"name" binding:"required" json:"name"`
	Email    string `form:"email" binding:"required,email" json:"email"`
	Password string `form:"password" binding:"required,min=6" json:"password"`
}

type UpdateUserRequest struct {
	ID       uint32 `form:"id" binding:"required,gte=1"`
	Name     string `form:"name" json:"name"`
	Email    string `form:"email" binding:"omitempty,email" json:"email"`
	Password string `form:"password" binding:"omitempty,min=6" json:"password"`
	Age      uint8  `form:"age" binding:"omitempty,min=0,max=125" json:"age"`
	Gender   string `form:"gender" binding:"omitempty,oneof=男 女" json:"gender"`
	Desc     string `form:"desc" binding:"omitempty,max=100" json:"desc"`
}

type FindUserByIdRequest struct {
	ID uint32 `form:"id" binding:"required,gte=1"`
}
